﻿using Teigha.TD;

namespace OdaOperation.Model
{
    /// <summary>
    /// 导出 CAD 实体信息的模型
    /// </summary>
    public class ExportDump
    {
        // 层的唯一标识符
        public ulong LayerId { get; set; }

        // 层的名称
        public string LayerName { get; set; }

        // 块的唯一标识符
        public ulong BlockId { get; set; }

        // 块的名称
        public string BlockName { get; set; }

        // 实体的类名
        public string ClassName { get; set; }

        // 实体的唯一标识符
        public ulong Id { get; set; }

        // 从 OdDbEntity 对象创建 ExportDump 实例的静态方法
        public static ExportDump From(OdDbEntity entity)
        {
            ExportDump exportDump = new ExportDump();
            exportDump.LayerId = entity.layerId().getHandle().ToUInt64();
            exportDump.LayerName = entity.layer();
            exportDump.BlockId = entity.blockId().getHandle().ToUInt64();
            exportDump.BlockName = (entity.blockId().openObject() as OdDbBlockTableRecord)?.getName();
            exportDump.ClassName = entity.isA().name();
            exportDump.Id = entity.objectId().getHandle().ToUInt64();
            return exportDump;
        }
    }

}